package cn.zwx.member.svc.service.impl;

import cn.zwx.member.svc.domain.entity.DistrictsEntity;
import cn.zwx.member.svc.mapper.DistrictsMapper;
import cn.zwx.member.svc.service.DistrictsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangwenxue
 */
@Service
public class DistrictsServiceImpl implements DistrictsService {

    @Resource
    private DistrictsMapper districtsMapper;

    @Override
    public List<DistrictsEntity> getDistrictsList(Long districtsId) {
        // 查询下级行政区域
        LambdaQueryWrapper<DistrictsEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DistrictsEntity::getDistrictPid,districtsId);
        return districtsMapper.selectList(queryWrapper);
    }

    @Override
    public List<DistrictsEntity> getByIdList(List<Long> districtsIdList) {
        LambdaQueryWrapper<DistrictsEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(DistrictsEntity::getDistrictId,districtsIdList);
        return districtsMapper.selectList(queryWrapper);
    }
}
